﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Question.ascx.cs" Inherits="SmsVotes.SmsVoting.Question" %>
<%@ Register Src="../Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="../Footer.ascx" TagName="Footer" TagPrefix="uc1" %>

<script type="text/javascript">
    var Question = {
        HasAnswers: function() {
            if ($get('<%= hfAnswersCount.ClientID %>').value == 0) {
                alert('Введите хотя бы 1 ответ');
                return false;
            }
            else
                return true;
        }
    }
    
</script>

<uc1:Header ID="Header" runat="server" />
<table class="PAGE" align="center" cellspacing="0" cellpadding="0">
    <tr valign="top">
        <td class="PAGE_BORDER_LEFT">
            <img src="images/body_left_bg.jpg" />
        </td>
        <td>
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                    <td class="TEXT_LEFT" valign="top">
                        <!-- TEXT -->
                        <table cellpadding="2" cellspacing="2" border="0" align="center">
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:RequiredFieldValidator runat="server" ID="rfvQuestionName" ControlToValidate="tbQuestion"
                                        ErrorMessage="Введите название вопроса" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" valign="top">
                                    Вопрос:
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="tbQuestion" runat="server" TextMode="MultiLine" Rows="5"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Тип диаграммы:
                                </td>
                                <td align="left">
                                    <asp:DropDownList ID="ddlDiagramType" runat="server">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:RequiredFieldValidator runat="server" ID="rfvDuration" ControlToValidate="tbDuration"
                                        ErrorMessage="Введите время автосмены вопроса" Display="Dynamic"></asp:RequiredFieldValidator>
                                    <asp:RangeValidator ID="rvDuration" runat="server" ControlToValidate="tbDuration"
                                        ErrorMessage="Время автосмены введено неправильно" Type="Integer" MinimumValue="0"
                                        MaximumValue="99999" Display="Dynamic">
                                    </asp:RangeValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Время автосмены вопроса:<br />
                                    (0 - смена в ручную)
                                </td>
                                <td align="left" valign="top">
                                    <asp:TextBox ID="tbDuration" runat="server" MaxLength="5" Text="0"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                </td>
                                <td align="left">
                                    <asp:Button ID="btnPopupTarget" runat="server" Style="display: none;" />
                                    <asp:Panel ID="pAddAnswer" runat="server" CssClass="modalPopup" Style="display: none;
                                        width: 400px;">
                                        <div>
                                            <asp:TextBox ID="tbAnswer" runat="server" TextMode="MultiLine" Rows="5" ValidationGroup="Answer"></asp:TextBox>
                                        </div>
                                        <asp:RequiredFieldValidator runat="server" ID="rfvAnswer" ControlToValidate="tbAnswer"
                                            ErrorMessage="Введите ответ" Display="Static" ValidationGroup="Answer"></asp:RequiredFieldValidator>
                                        <div>
                                            <asp:LinkButton runat="server" ID="lbtnSaveAnswer" Text="Сохранить" OnClick="lbtnSaveAnswer_Click"
                                                ValidationGroup="Answer"></asp:LinkButton>
                                            <asp:LinkButton runat="server" ID="lbtnCancelAnswer" Text="Отменить" CausesValidation="false"></asp:LinkButton>
                                        </div>
                                    </asp:Panel>
                                    <ajaxToolkit:ModalPopupExtender ID="mpeAnswer" runat="server" BackgroundCssClass="modalBackground"
                                        PopupControlID="pAddAnswer" TargetControlID="btnPopupTarget" BehaviorID="mpeAnswerBehavior"
                                        CancelControlID="lbtnCancelAnswer">
                                    </ajaxToolkit:ModalPopupExtender>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Список ответов:
                                </td>
                                <td align="left">
                                    <asp:ListView runat="server" ID="lvAnswers" OnItemCommand="lvAnswers_ItemCommand">
                                        <LayoutTemplate>
                                            <div>
                                                <ul id="answersList" style="cursor: hand; cursor: pointer;">
                                                    <li id="itemPlaceholder" runat="server"></li>
                                                </ul>
                                            </div>
                                        </LayoutTemplate>
                                        <ItemTemplate>
                                            <li runat="server" id="answer">
                                                <%# Eval("Name") %><asp:LinkButton ID="lbtnEditAnswer" runat="server" Text="Редактировать"
                                                    CommandName="EditAnswer" CommandArgument='<%# Eval("Guid") %>'></asp:LinkButton><asp:LinkButton
                                                        ID="lbtnDeleteAnswer" runat="server" Text="Удалить" OnClientClick="return confirm('Вы действительно хотите удалить ответ?');"
                                                        CommandName="DeleteAnswer" CommandArgument='<%# Eval("Guid") %>'></asp:LinkButton>
                                            </li>
                                        </ItemTemplate>
                                    </asp:ListView>
                                    <asp:LinkButton ID="lbtnCreateAnswer" runat="server" Text="Добавить ответ" OnClick="lbtnCreateAnswer_Click"></asp:LinkButton>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:HiddenField ID="hfAnswersCount" runat="server" Value="0" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:LinkButton ID="lbtnCreateNextQuestion" runat="server" class="abutton" Text="Сохранить вопрос"
                                        OnClientClick="return Question.HasAnswers()" OnClick="lbtnCreateNextQuestion_Click"></asp:LinkButton>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:LinkButton ID="lbtnRedirectToSort" runat="server" CausesValidation="false" Text="Вернуться к голосованию"
                                        class="abutton" OnClick="lbtnRedirectToSort_Click"></asp:LinkButton>
                                </td>
                            </tr>
                        </table>
                        <!-- TEXT -->
                    </td>
                    <td width="1" background="../images/splitter.jpg">
                        <img src="../images/splitter_top.jpg" alt="" />
                    </td>
                    <td class="TEXT_RIGHT" valign="top" alt="">
                        <!-- Navigation -->
                        <img src="../images/spacer2.gif" />
                    </td>
                </tr>
            </table>
        </td>
        <td class="PAGE_BORDER_RIGHT">
            <img src="images/body_right_bg.jpg">
        </td>
    </tr>
</table>
<uc1:Footer ID="Footer1" runat="server" />
